package com.sinai.mshab.format.validation;

import com.sinai.mshab.format.util.Observable;

/**
 * The {@code Validator} interface provides a guide to how validators can be
 * built and applied to widgets that are added to the {@link FormatPanel}.
 * 
 * @author Arthur Kalmenson
 * 
 * @param <T>
 *            the type of widget this validator deals with.
 */
public interface Validator<T> extends Observable {

	/**
	 * Sets the widget that this {@code Validator} will validate.
	 * 
	 * @param widget
	 *            the widget that this {@code Validator} will validate.
	 */
	public void setWidget(T widget);

	/**
	 * Returns the widget that this {@code Validator} validates.
	 * 
	 * @return the widget that this {@code Validator} validates.
	 */
	public T getWidget();

	/**
	 * Returns true if its containing widget is valid and false otherwise.
	 * 
	 * @return true if its containing widget is valid and false otherwise.
	 */
	public boolean validate();
}
